<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>Login - KitAdminCore</title>
    <script>
        if (window != window.top) top.location.href = self.location.href;
    </script>
    <link href="./plugins/layui/css/layui.css" rel="stylesheet" />
    <link href="./plugins/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <link href="./plugins/sideshow/css/normalize.css" rel="stylesheet" />
    <link href="./plugins/sideshow/css/demo.css" rel="stylesheet" />
    <link href="./plugins/sideshow/css/component.css" rel="stylesheet" />
    <!--[if IE]>
        <script src="./plugins/sideshow/js/html5.js"></script>
    <![endif]-->
    <style>
        /** kit_admin-v1.1.0 MIT License By http://kit/zhengjinfan.cn e-mail:zheng_jinfan@126.com */
        .kit-login-bg{background-color:#393D49}.kit-login-box{width:390px;margin:10% auto;background-color:#666;background-color:rgba(46,46,46,.61);border-radius:10px;color:#f0f8ff;box-shadow:0 0 20px 0 #009688}.kit-login-box header{height:39px;padding:10px;border-bottom:1px solid rgba(0,150,136,.5)}.kit-login-box header h1{text-align:center;font-size:25px;line-height:40px}.kit-login-box .kit-login-main{padding:30px 50px 0}.kit-login-box .kit-login-main .layui-input:focus{border-color:#009688!important}.kit-login-main .layui-form-item{position:relative}.kit-login-main .layui-form-item .kit-login-icon{position:absolute;color:#ccc;top:10px;left:10px}.kit-login-main .layui-form-item input{padding-left:34px}.kit-login-box footer{height:85px}.kit-login-box footer p{line-height:35px;text-align:center}.kit-pull-left{float:left!important}.kit-pull-right{float:right!important}.kit-clear{clear:both}.kit-login-remember{line-height:38px}.kit-login-remember .layui-form-checkbox[lay-skin=primary] span{color:#fff}.kit-login-remember .layui-form-checked[lay-skin=primary] i{border-color:#009688;background-color:#009688}.kit-login-remember .layui-form-switch{margin-top:0}.kit-login-code-box{position:relative;padding:10px}.kit-login-code-box input{position:absolute;width:100px}.kit-login-code-box img{cursor:pointer;position:absolute;left:115px;height:38px}
        canvas {
            position: absolute;
            z-index: -1;
        }
        
        .kit-login-box header h1 {
            line-height: normal;
        }
        
        .kit-login-box header {
            height: auto;
        }
        
        .content {
            position: relative;
        }
        
        .codrops-demos {
            position: absolute;
            bottom: 0;
            left: 40%;
            z-index: 10;
        }
        
        .codrops-demos a {
            border: 2px solid rgba(242, 242, 242, 0.41);
            color: rgba(255, 255, 255, 0.51);
        }
        
        .kit-pull-right button,
        .kit-login-main .layui-form-item input {
            background-color: transparent;
            color: white;
        }
        
        .kit-login-main .layui-form-item input::-webkit-input-placeholder {
            color: white;
        }
        
        .kit-login-main .layui-form-item input:-moz-placeholder {
            color: white;
        }
        
        .kit-login-main .layui-form-item input::-moz-placeholder {
            color: white;
        }
        
        .kit-login-main .layui-form-item input:-ms-input-placeholder {
            color: white;
        }
        
        .kit-pull-right button:hover {
            border-color: #009688;
            color: #009688
        }
    </style>
</head>


<body class="kit-login-bg">
    <div class="container demo-1">
        <div class="content">
            <div id="large-header" class="large-header">
                <canvas id="demo-canvas"></canvas>
                <div class="kit-login-box">
                    <header>
                        <h1>流程配置管理系统</h1>
                    </header>
                    <div class="kit-login-main">
                        <form class="layui-form" method="post">
                            <div class="layui-form-item">
                                <label class="kit-login-icon">
                                    <i class="layui-icon">&#xe612;</i>
                                </label>
                                <input type="text" name="userName"  lay-verify="required" autocomplete="off" placeholder="这里输入用户名." class="layui-input">
                            </div>
                            <div class="layui-form-item">
                                <label class="kit-login-icon">
                                    <i class="layui-icon">&#xe642;</i>
                                </label>
                                <input type="password" name="password" lay-verify="required" autocomplete="off" placeholder="这里输入密码." class="layui-input">
                            </div>
                    <!--        <div class="layui-form-item">
                                <label class="kit-login-icon">
                                    <i class="layui-icon">&#xe642;</i>
                                </label>
                                <input type="number" name="validCode" lay-verify="required|number" autocomplete="off" placeholder="输入右侧计算结果." class="layui-input">
                                <span class="form-code" id="changeCode" style="position:absolute;right:2px; top:2px;">
                                    <img src="./build/images/GetVerfiyCode.png" id="refImg" style="cursor:pointer;" title="点击刷新"/>
                                </span>
                            </div>-->
                            <div class="layui-form-item">
                               <!-- <div class="kit-pull-left kit-login-remember">
                                    <input type="checkbox" name="rememberMe" value="true" lay-skin="primary" checked title="记住帐号?">
                                </div>-->
                                <div class="kit-pull-right">
                                    <button class="layui-btn layui-btn-primary" lay-submit lay-filter="login">
                                        <i class="fa fa-sign-in" aria-hidden="true"></i> 登录
                                    </button>
                                </div>
                                <div class="kit-clear"></div>
                            </div>
                        </form>
                    </div>
                    <footer>
                       <!-- <p>FK ADMIN © <a href="http://blog.zhengjinfan.cn" style="color:white; font-size:18px;" target="_blank">www.zhengjinfan.cn</a></p>-->
                    </footer>
                </div>
            </div>
        </div>
    </div>
    <!-- /container -->

    <script src="./plugins/layui/layui.js"></script>
    <script src="./plugins/sideshow/js/TweenLite.min.js"></script>
    <script src="./plugins/sideshow/js/EasePack.min.js"></script>
    <script src="./plugins/sideshow/js/rAF.js"></script>
    <script src="./plugins/sideshow/js/demo-1.js"></script>
    <script>
        layui.config({
            base: '/activiti/ui/js/modules/',
            version: false
        }).use(['layer', 'form', 'ht_cookie', 'ht_config'], function () {
            var $ = layui.jquery, form = layui.form, cookie = layui.ht_cookie, ht_config = layui.ht_config;

            //判断是否已登录，如果已登录，则直接进入主页
            if (cookie.getToken() != null && cookie.getToken() != "") {
                top.location.href = 'index.html';
            }

            $('#changeCode').on('click', function () {
                $('#changeCode > img')[0].src = './build/images/GetVerfiyCode.png';
            });

            //系统编码统一通过头信息传入后台
            //清理左侧菜单缓存
            var index = layer.load(2, {shade: [0.3, '#333']});
            layer.close(index);
            form.on('submit(login)', function (data) {
                console.info(ht_config.loginUrl, data.field)
                $.ajax({
                    type: "POST",
                    url: ht_config.loginUrl,
                    contentType: "application/json; charset=utf-8",
                    data: JSON.stringify(data.field),
                    async: false,
                    dataType: "json",
                    beforeSend: function (xhr) {
                        xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
                        xhr.setRequestHeader("app", ht_config.app);
                    },
                    success: function (data) {
                        console.info(data);
                        if (data && data["token"] != null & data["token"] != "") {
                            cookie.setToken(data["token"]);
                            cookie.setRefreshToken(data["refreshToken"]);
                            top.location.href = 'index.html';
                        } else {
                            layer.alert("登录失败，请联系管理员");
                        }
                    },
                    error: function (xhr, exception, errorThrown) {
                        if (xhr.status == '401' || xhr.status == '403') {
                            layer.alert("用户名或密码错误，请重新登录");
                        }
                        if (xhr.status == '500') {
                            layer.alert("服务器错误，请联系管理员");
                        }
                        if (xhr.status == '0') {
                            layer.alert("网络错误，请检查网络")
                        }
                        $(':input', '#loginForm').not(':button,:submit,:reset,:hidden').val('').removeAttr('checked').removeAttr('checked');
                    }
                });
                return false;

                // $.post(data.form.action, data.field, function(res) {
                //     if (!res.rel) {
                //         layer.msg(res.msg, {
                //             icon: 2
                //         });
                //         loadIndex && layer.close(loadIndex);
                //         $('#changeCode').click(); //刷新验证码
                //     } else {
                //         setTimeout(function() {
                //             location.href = '/'
                //         }, 1500);
                //     }
                // }, 'json');
            });
        });
    </script>

</body>

</html>